import datetime

class LibaryItem:
    # 属性   方法
    #封装、继承、多态

    def __init__(self,t, a, i):
        self.__Title= t
        self.__Author_Artist= a
        self.__ItemID = i
        self.__OnLoan = False
        self.__BorrowerID=""
        self.__DueDate = datetime.date.today()


    def GetTitle(self):
        return self.__Title

    def Borrowing(self,b):
        self.__BorrowerID = b.getBorrowerID()
        self.OnLoan = True
        self.__DueDate = self.__DueDate + datetime.timedelta(weeks = 3)
        b.updateItemsOnLoan(10)

    def returnning(self):
        self.__BorrowerID = ""
        self.OnLoan = False
        self.__DueDate = datetime.date.today()

    def PrintDetails(self):
        print(self.__Title, ',', self.__Author_Artist, ', ')
        print(self.__ItemID,', ', self.__OnLoan, ', ', self.__DueDate)

class Book (LibaryItem):
     #super() <==> LibaryItem
    def __init__(self,t, a, i):
        LibaryItem.__init__(self, t, a, i)
        self.__IsRequested = False
        self.__RequestedBy = 0

    def GetlsRequested(self):
        return(self. __IsRequested)

    def SetLiRequested (self) :
        self. __IsRequested = True

    # def PrintDetails(self):
    #     LibaryItem.PrintDetails(self)
    #     print(self.__IsRequested,self.__RequestedBy)

class CD(LibaryItem):
    def init (self, t, a, i):
        LibaryItem.__init__(t,a,i)
        self.__Genre = ""
    def GetGestre(self):
        return self.__Genre
    def SetGenre(self, g):
        self.__Genre = g

class Borrower():
    def __init__(self,name,address,id):
        self.__borrowerName = name
        self.__emailAddress = address
        self.__borrowerID = id
        self.__itemsOnLoan = 0
    def getBorrowerName(self):
        return self.__borrowerName
    def getEmailAddress(self):
        return self.__emailAddress
    def getBorrowerID(self):
        return self.__borrowerID
    def getItemsOnLoan(self):
        return self.__itemsOnLoan
    def updateItemsOnLoan(self,n):
        self.__itemsOnLoan = self.__itemsOnLoan + n
    def printDetails(self):
        print('borrower name is:',self.__borrowerName)
        print('email address is:', self.__emailAddress)
        print('borrower ID is:', self.__borrowerID)
        print('items on loan is:', self.__itemsOnLoan)



if __name__ == '__main__':
    book = Book("CS","Marvin","001")
    book.PrintDetails()
    # book.Borrowing()
    book.PrintDetails()

    b = Borrower("1","2","3")
    book.Borrowing(b)